package com.cloud.controller;

import com.cloud.entity.CommonResult;
import com.cloud.entity.Payment;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * <h3>springcloud02</h3>
 * <p></p>
 *
 * @author : zhengyue
 * @date : 2020-06-29 21:50
 **/
@RestController
public class ProviderController {
    @Value("${server.port}")
    private String serverPort;

    public static HashMap<Long, Payment> hashMap = new HashMap<Long, Payment>();
    static {
        hashMap.put(1L, new Payment(1L, "111111"));
        hashMap.put(2L, new Payment(2L, "222222"));
        hashMap.put(3L, new Payment(3L, "333333"));
    }

    @GetMapping(value = "paymentSQL/{id}")
    public CommonResult<Payment> paymentSQl(@PathVariable("id") Long id) {
        Payment payment = hashMap.get(id);
        return new CommonResult<Payment>(200, "from mysql, serverPort：" + serverPort, payment);
    }
}
